import vv from "../../Common/vv";
import GameDataInstance from "../../Common/GameDataInstance";

// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class LGRankingview extends cc.Component {

   
    // onLoad () {}


    //排行榜panel
    @property(cc.Node)
    rankingPanel:cc.Node = null


    //返回按钮
    @property(cc.Node)
    returnBtn:cc.Node = null

    //我的排名
    @property(cc.Node)
    myrank:cc.Node = null

    //我的头像
    @property(cc.Node)
    myicon:cc.Node = null

    //我的名字
    @property(cc.Node)
    myname:cc.Node = null

    //我的分数
    @property(cc.Node)
    myscore:cc.Node = null

    start () {

        this.myrank.getComponent(cc.Label).string = GameDataInstance.Instance.mypaihangdata.rank
        vv.SetWeChatImageByWebUrl(GameDataInstance.Instance.mypaihangdata.avatar,this.myicon)
        this.myname.getComponent(cc.Label).string = GameDataInstance.Instance.mypaihangdata.nickname
        this.myscore.getComponent(cc.Label).string = GameDataInstance.Instance.mypaihangdata.credit3

        vv.btnClick(this.returnBtn,()=>
        {
            this.node.destroy()
        })

    }


    //刷新数据
    requestui(data:any)
    {
        vv.instantiateItem(this.rankingPanel,data.length,()=>
        {
            for(let i =0 ;i<data.length;i++)
            {
                let rankItem = this.rankingPanel.children[i]
                rankItem.getComponent('LgRankItem').setData(data[i])
            }
        })
    }



    // update (dt) {}
}
